package com.mars.upms.rpc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mars.base.common.utils.Paginator;
import com.mars.base.service.support.BaseService;
import com.mars.upms.dao.mapper.UpmsGroupMapper;
import com.mars.upms.dao.mapper.UpmsUserGroupAssignMapper;
import com.mars.upms.dto.UpmsUserDto;
import com.mars.upms.entity.UpmsGroup;
import com.mars.upms.entity.UpmsUserGroupAssign;
import com.mars.upms.rpc.api.UpmsGroupService;

@Service
public class UpmsGroupServiceImpl extends BaseService<UpmsGroup, Integer> implements UpmsGroupService {
	
	@Autowired
	private UpmsGroupMapper mapper ;

	@Autowired
	private UpmsUserGroupAssignMapper userGroupAssignMapper ;
	
	@Override
	public PageInfo<UpmsUserDto> getGroupUserAssignList(Paginator paginator, UpmsUserDto dto) {
		Page<UpmsUserDto> page = PageHelper.startPage(paginator.getPage(), paginator.getRows()) ;
		this.mapper.getGroupUserAssignList(paginator, dto);
		
		return new PageInfo<UpmsUserDto>(page) ;
	}

	@Override
	public void removeGroupUser(Integer groupAssingId) {
		UpmsUserGroupAssign entity = new UpmsUserGroupAssign() ;
		entity.setId(groupAssingId);
		this.userGroupAssignMapper.delete(entity) ;
	}

}
